from core import Validator


class OneOfValidator(Validator):
    """
    Validates ('makes sure') the value is one of a predefined set of values.
    If not, raises an error
    
    * subcon - the subconstruct to validate
    * valids - a set of valid values
    """
    __slots__ = ["valids"]
    def __init__(self, subcon, valids):
        Validator.__init__(self, subcon)
        self.valids = valids
    def _validate(self, obj):
        return obj in self.valids

class NoneOfValidator(Validator):
    """
    Validates ('makes sure') the value is NOT one of a predefined set of values. 
    If it is, raises an error
    
    * subcon - the subconstruct to validate
    * valids - a set of invalid values
    """
    __slots__ = ["invalids"]
    def __init__(self, subcon, invalids):
        Validator.__init__(self, subcon)
        self.invalids = invalids
    def _validate(self, obj):
        return obj not in self.invalids
    



